package com.google.android.material.internal;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.core.view.ViewCompat;
import o.aqu.f;
import o.aqu.n;
import o.asa;
import o.hx;
import o.ij;

@RestrictTo({d.LIBRARY_GROUP})
public class ScrimInsetsFrameLayout extends FrameLayout {
    private Rect ˊ;
    Drawable ˋ;
    Rect ॱ;

    public ScrimInsetsFrameLayout(Context context) {
        this(context, null);
    }

    public ScrimInsetsFrameLayout(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public ScrimInsetsFrameLayout(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ˊ = new Rect();
        TypedArray ॱ = asa.ॱ(context, attributeSet, n.ˋꞌ, i, f.ʽ, new int[0]);
        this.ˋ = ॱ.getDrawable(n.ˌˏ);
        ॱ.recycle();
        setWillNotDraw(true);
        ViewCompat.ˋ(this, new hx(this) {
            final /* synthetic */ ScrimInsetsFrameLayout ˊ;

            {
                this.ˊ = r1;
            }

            public ij ˋ(View view, ij ijVar) {
                if (this.ˊ.ॱ == null) {
                    this.ˊ.ॱ = new Rect();
                }
                this.ˊ.ॱ.set(ijVar.ˏ(), ijVar.ˎ(), ijVar.ˋ(), ijVar.ˊ());
                this.ˊ.ˋ(ijVar);
                ScrimInsetsFrameLayout scrimInsetsFrameLayout = this.ˊ;
                boolean z = !ijVar.ॱ() || this.ˊ.ˋ == null;
                scrimInsetsFrameLayout.setWillNotDraw(z);
                ViewCompat.ˎ(this.ˊ);
                return ijVar.ॱॱ();
            }
        });
    }

    public void draw(@NonNull Canvas canvas) {
        super.draw(canvas);
        int width = getWidth();
        int height = getHeight();
        if (this.ॱ != null && this.ˋ != null) {
            int save = canvas.save();
            canvas.translate((float) getScrollX(), (float) getScrollY());
            this.ˊ.set(0, 0, width, this.ॱ.top);
            this.ˋ.setBounds(this.ˊ);
            this.ˋ.draw(canvas);
            this.ˊ.set(0, height - this.ॱ.bottom, width, height);
            this.ˋ.setBounds(this.ˊ);
            this.ˋ.draw(canvas);
            this.ˊ.set(0, this.ॱ.top, this.ॱ.left, height - this.ॱ.bottom);
            this.ˋ.setBounds(this.ˊ);
            this.ˋ.draw(canvas);
            this.ˊ.set(width - this.ॱ.right, this.ॱ.top, width, height - this.ॱ.bottom);
            this.ˋ.setBounds(this.ˊ);
            this.ˋ.draw(canvas);
            canvas.restoreToCount(save);
        }
    }

    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (this.ˋ != null) {
            this.ˋ.setCallback(this);
        }
    }

    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (this.ˋ != null) {
            this.ˋ.setCallback(null);
        }
    }

    protected void ˋ(ij ijVar) {
    }
}
